package com.shty.wd.utils.module.related;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import net.sf.json.JSONObject;

public class Entity {

	protected boolean hasRelations; // whether this entity is related to China
	protected String basis; // the proofs
	protected Map<String,String> result ; // the fields in this entity
	
	public Entity() {	
		setResult(new HashMap<String, String>()) ;
	}

	public boolean getHasRelations() {
		return hasRelations;
	}

	public void setHasRelations(boolean hasRelations) {
		this.hasRelations = hasRelations;
	}

	public Map<String,String> getResult() {
		return result;
	}

	public void setResult(Map<String,String> result) {
		this.result = result;
	}
	
	@Override
	public String toString() {
		return "Entity [hasRelations=" + hasRelations + ", basis=" + basis + ", result=" + result + "]";
	}

	public String getBasis() {
		return basis;
	}

	public void setBasis(String basis) {
		this.basis = basis;
	}
	
	public String creatJSON(){
		JSONObject entityJSON = new JSONObject();
		Map<String,String> result = getResult();
		for (Entry<String,String> entry : result.entrySet()) {
			if(entry.getKey().equals("result")==false)
				entityJSON.put(entry.getKey(), entry.getValue());
		}
		entityJSON.put("hasRelations", getHasRelations()) ;
		entityJSON.put("basis", getBasis());
		return entityJSON.toString();
	}

}
